#ifndef READER_H
#define READER_H

#include <QMetaType>
#include <QMutex>
#include <QThread>

#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

class Reader : public QThread {
    Q_OBJECT
public:
    Reader(int dev = 0);
    Reader(string str);

    // thread loop
    void run() override;

    // start thread
    bool start(QThread::Priority = InheritPriority);

    // stop thread
    void stop() { running = false; }

signals:
    void updateImage(Mat*);

private:
    QMutex running_mutex;
    bool running;

    Mat img_in;
    VideoCapture* cap;
};

#endif // READER_H
